package list;


import java.util.Iterator;
import java.util.LinkedList;

public class MyLinkedListDemo {
    public static void main(String[] args) {
        LinkedList<String>list = new LinkedList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        //迭代器
        Iterator<String>it =list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("------------");
        //增强for
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("------------");
        //普通遍历
        for (int i = 0; i < list.size(); i++) {
            String st = list.get(i);
            System.out.println(st);
        }
    }
}
